<?php

/**
 * tax_codes actions.
 *
 * @package    erp-crm
 * @subpackage tax_codes
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class tax_codesActions extends sfActions
{
  public function executeIndex(){
    $this->listTaxCodesForm = new ListTaxCodesForm();
    $this->listTaxCodesList = ListTaxCodesPeer::doSelectSortByName();
  }
  
  public function executeEdit($request){
    $this->listTaxCodesForm = new ListTaxCodesForm(ListTaxCodesPeer::retrieveByPk($request->getParameter('iden')));
    $this->forward404Unless($this->listTaxCodesForm );
    $this->listTaxCodesList = ListTaxCodesPeer::doSelectSortByName();
    $this->setTemplate('index');
  }
  
  public function executeInsert($request){
    $list_tax_codes = $request->getParameter('list_tax_codes');
    $list_tax_codes['iden'] = myStringGenerator::getIden();
    $this->listTaxCodesForm = new ListTaxCodesForm();
    $this->listTaxCodesForm->bind($list_tax_codes);
    if($this->listTaxCodesForm->isValid()){
      $this->listTaxCodesForm->save();
      $this->redirect('tax_codes/index');
    }else{
      $this->listTaxCodesList = ListTaxCodesPeer::doSelectSortByName();
      $this->setTemplate('index');
    }
  }

  public function executeUpdate($request){
    $list_tax_codes = $request->getParameter('list_tax_codes');
    $this->listTaxCodesForm = new ListTaxCodesForm(ListTaxCodesPeer::retrieveByPk($list_tax_codes['iden']));
    $this->forward404Unless($this->listTaxCodesForm);
    $this->listTaxCodesForm->bind($request->getParameter('list_tax_codes'));
    if($this->listTaxCodesForm->isValid()){
      $this->listTaxCodesForm->save();
      $this->redirect('tax_codes/index');
    }else{
      $this->listTaxCodesList = ListTaxCodesPeer::doSelectSortByName();
      $this->setTemplate('index');
    }
  }

  public function executeDelete($request){
    $list_tax_codes = ListTaxCodesPeer::retrieveByPk($request->getParameter('iden'));
    $this->forward404Unless($list_tax_codes);
    $list_tax_codes->delete();
    $this->redirect('tax_codes/index');
  }
  
}
